home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9220 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  7.5 KB

  1. Path: watnews.watson.ibm.com!ncohen
  2. From: ncohen@watson.ibm.com (Norman H. Cohen)
  3. Newsgroups: comp.lang.ada,comp.lang.c
  4. Subject: Re: C/C++ knocks the crap out of Ada
  5. Date: 8 Mar 1996 21:11:32 GMT
  6. Organization: IBM T.J. Watson Research Center
  7. Distribution: world
  8. Message-ID: <4hq7q4$qik@watnews1.watson.ibm.com>
  9. References: <JSA.96Feb16135027@organon.com>
  10.  <4gaa6l$8mk@post.gsfc.nasa.gov> <4gd94r$isu@mack.rt66.com>
  11.  <1996Feb22.005518.13396@leeweyr.sccsi.com>
  12.  <4gvrffINNlqo@anvil.ugrad.cs.ubc.ca>
  13.  <4h4j31$1ga3@watnews1.watson.ibm.com>
  14.  <TANMOY.96Feb29144112@qcd.lanl.gov>
  15.  <4hf485$1mgv@watnews1.watson.ibm.com> <TANMOY.96Mar4155315@qcd.lanl.gov>
  16. Reply-To: ncohen@watson.ibm.com
  17. NNTP-Posting-Host: rios8.watson.ibm.com
  18.  
  19. In article <TANMOY.96Mar4155315@qcd.lanl.gov>, tanmoy@qcd.lanl.gov
  20. (Tanmoy Bhattacharya) writes: 
  21.  
  22. |> In article <4hf485$1mgv@watnews1.watson.ibm.com>
  23. |> ncohen@watson.ibm.com (Norman H. Cohen) writes: 
  24. |>
  25. |> NHC: Famous last words!  That's how we all started out! :-)
  26. |>
  27. |> Yup. I am replying because there is precisely one mistake in your
  28. |> argument. (Most of it I actually agree with). But, as I am replying, I
  29. |> also put forth some arguments.
  30.  
  31. Yes, in the first stage addicts always deny their addictions. :-)
  32.  
  33. ...
  34. |> NHC: The Ada language was originally designed in response to a set of
  35. |> NHC: requirements promulgated by its intended users.  The revision was driven
  36. |> NHC: by requirements that arose in the programming community, which provided
  37. |> NHC: plentiful input to a very open process.
  38. |>
  39. |> I agree that the language design team got input from the target
  40. |> community: it however did not have the `field testing' that C got in
  41. |> its pre-standard phase. That is what I meant.
  42.  
  43. True of Ada 83, but not of Ada 95.
  44.  
  45. ...
  46. |> By the way, doesn't Ada require runtime checks? I thought it did, but
  47. |> I haven't looked at the language for a long time now: and have never
  48. |> programmed anything beyond `Hello world' in it. Most of the arguments
  49. |> in this post are incorrect if this assumption is false.
  50.  
  51. Yes, Ada certainly does required run-time checks!
  52.  
  53. ...
  54. |> NHC:                                                                  The C
  55. |> NHC: standard contains to requirement to detect any form of nonconformance at
  56. |> NHC: compile time.  Section 1.7 of the standard states, "A _conforming_hosted_
  57. |> NHC: _implementation_ shall accept any strictly conforming program.  A
  58. |> NHC: _conforming_freestanding_implementation_ shall accept any strictly
  59. |> NHC: conforming program in which the use of the features specified in the
  60. |> NHC: library section (Section 4) is confined to the contents of the standard
  61. |> NHC: <float.h>, <limits.h>, <stdarg.h>, and <stddef.h>." The converse ("A
  62. |> NHC: conforming implementation shall reject any program that is not strictly
  63. |> NHC: conforming.") is noticeably absent.  Indeed, the paragraph continues, "A
  64. |> NHC: conforming implementation may have extensions (including additional
  65. |> NHC: library functions), provided they do not alter the behavior of any
  66. |> NHC: strictly conforming program."
  67. |>
  68. |> This is the only mistake in your post: 
  69. |>
  70. |> The standard requires a diagnostic whenever any constraint or syntax
  71. |> rule is violated. (5.1.1.3). After diagnosing the error, it can do
  72. |> whatsoever it pleases.
  73.  
  74. I think ANSI ripped me off!  I paid them $60 for a copy of the C
  75. standard, and the one they sent me only goes up to Section 4. :-)
  76. (Or perhaps there's a typo in your citation? Please clarify.)
  77.  
  78. |> In fact, sometimes vendors deliberately want something to invoke
  79. |> `undefined' behaviour instead of violating a constraint, so that they
  80. |> can provide an extension that does not need a diagnostic. Some of them
  81. |> (e.g. $ in a macro name) even get accepted. But, by and large, a
  82. |> compiler cannot silently compile these category of errors.
  83.  
  84. I don't understand how this can be reconciled with your previous
  85. statement.
  86.  
  87. ...
  88. |>                           The Ada community is presumably a group of
  89. |> people who need to write code which will be reused for a long time,
  90.  
  91. That's accurate.
  92.  
  93. |> and probably on stable enough platforms that one does not have to work
  94. |> around machine/compiler deficiencies.
  95.  
  96. I don't think the platforms on which Ada programs run are particularly
  97. more or less stable than those on which, say, C programs run.  I don't
  98. see what you're getting at.
  99.  
  100. |>                                       It probably is also used by the
  101. |> community to whom safety is so important that it needs to be enforced
  102. |> by the language, instead of by programmer's habit and training; and by
  103. |> coding standards?
  104.  
  105. Not INSTEAD OF programmer's habit and training, but IN ADDITION TO.  It
  106. is used by a community that considers it irresponsible to have a
  107. program's correctness rely entirely on the imperfect ability of
  108. programmers to ferret out error by desk checking and testing.
  109.  
  110. |> Am I wrong? If I am right, I have little to say about those needs. I
  111. |> am a scientist by profession: to me it is important to get my results
  112. |> with the current technology, and not have to wait for future
  113. |> advances.
  114.  
  115. I'm not sure what current technology versus future advances has to do
  116. with your argument.  (In particular, I hope you realize that Ada is very
  117. much a current technology.)
  118.  
  119. |>           Heck, my theory is more likely to be wrong than my
  120. |> programming;
  121.  
  122. Either you're a much  better programmer than most of us or you have a
  123. very poor track record as a theoretician.
  124.  
  125. |>              and I would rather write my code in a `manifestly
  126. |> correct' way and thoroughly check my code (and cross check it);
  127.  
  128. Typical programming problems can be solved in either a "manifestly
  129. correct" but slow way, or in a more obscure but faster way.  What you
  130. seem to be saying here is that you are willing to sacrifice performance
  131. for the sake of greater confidence in the correctness of your prrogram.
  132. But then you continue: 
  133.  
  134. |>                                                                 than
  135. |> write in a language that will check every operation that I do. I
  136. |> typically code for 3 months human time, and run for 1 year's cpu time: 
  137. |> I do not really care if that 3 months become four, but I can't afford
  138. |> the 1 year becoming 13 months!
  139.  
  140. Even if we accept that using C instead of Ada only increases your
  141. development and debugging time by 33%, and that using Ada instead of C
  142. increases the execution time of your program by 1/12, I find it hard to
  143. understand why it is okay for your 16 months to be split 4+12, but not
  144. 3+13, especially since 3+13 gives you a program in whose correctness you
  145. can have greater confidence.  (But note that even if you used Ada for the
  146. sake of its compile-time consistency checks, and for its run-time
  147. checks during your three months of development, but suppressed all the
  148. run-time checks during your year of production runs, you would still be
  149. better off than if you had used C, and your program would run just as
  150. fast.)
  151.  
  152. |> I have found that C can be used to write small understandable code
  153. |> with no overhead that I did not count on when I wrote my code.
  154.  
  155. Ada allows selective or general suppression of run-time checks.  For
  156. every C construct, there is a corresponding Ada construct that has the
  157. same cost when run with checks suppressed.  But many of the checks get
  158. optimized away (because the compiler deduces that they cannot possibly
  159. fail), or are not expensive enough to worry about.  Many programs,
  160. particularly scienitific programs, can be sped up significantly by
  161. suppressing checks in a few small critical inner loops, which can be
  162. scrutinized especially carefully.  The remaining checks contribute very
  163. little to the overall running time of the program.
  164.  
  165. --
  166. Norman H. Cohen    ncohen@watson.ibm.com
  167.